﻿<cfscript>
/** 
* ORM StudentCourse
* 
* @hint "Hibernate persistenter t_student_course. 学生学期选课记录表" 
* 
*/ 

component 
	displayname="public.service.orm.senate.StudentCourse" 
	output=false 
	persistent=true 
	selectBeforeUpdate=true dynamicInsert=true dynamicUpdate=true 
	cacheuse="Transactional" 
	entityname="StudentCourse" 
	table="t_student_course"
	{

	property type="string" name="ChooseID" column="scc_id" fieldtype="id" generator="assigned" hint="学生选课号";

	property type="string" name="TaskType" column="task_type" hint="教学任务类别";
	property type="string" name="CourseIndex" column="cidx" hint="课序号";
	property type="string" name="TaskID" column="task_id" hint="教学任务号";
	property type="string" name="StudyType" column="st" hint="课程修读类别代码 用于学费计算";
	property type="string" name="Retaking" column="retaking" hint="是否重修标志";
	
	property type="string" name="ChooseTime" column="choose_time" hint="选课时间";
	property type="string" name="ChargeTime" column="charge_time" hint="结算时间";
	property type="string" name="ChooseProp" column="choose_prop" hint="选课相关属性";

	property name="Term" fieldtype="many-to-one" fkcolumn="term_id" cfc="Term"  hint="学期";
	property name="Course" fieldtype="many-to-one" fkcolumn="cid" cfc="Course"  hint="课程";
	property name="ChooseTurn" fieldtype="many-to-one" fkcolumn="ct" cfc="ChooseTurn"  hint="选课轮次";
	property name="Student" fieldtype="many-to-one" fkcolumn="stu_id" cfc="Student"  hint="学生";
	property name="CourseProperty" fieldtype="many-to-one" fkcolumn="prop_id" cfc="CourseProperty"  hint="课程属性";
	
	/**
	* @hint "自定义主键规则"
	* 
	* @Student "学生"
	* @Course "课程"
	* @Term "学期"
	* @TaskType "教学任务类别"
	*/
	public string function getID( required Student, required Course, required Term, required string TaskType ) output=false {
		
		var nextID = arguments.Student.getStudentID() & "," & arguments.Course.getCourseID() & "," & arguments.Term.getTermID() & arguments.TaskType;

		/* 
			主键生成规则 
			
			选课号36位 8位学号 , 6位课程号 , 3位学期代码+教学任务类别

			Unique: STU_ID, CID, TERM_ID, TASK_TYPE
		*/
		return nextID;
	}
	
}

</cfscript>